{% extends 'base.html' %}
{% block content %}
<html>
<head>
    <script src="{{url_for('static',filename='module/module.js')}}"></script>
    <link rel="stylesheet" type="text/css" href="{{url_for('static',filename='module/module.css')}}">
    <script type="text/javascript">
        function delmudole(obj) {
            var cell1 = obj.parentNode.parentNode.children[0];
            var ids = cell1.innerHTML;
            var data = {'id':ids};
            $.ajax({
                type:'GET',
                url:"{{url_for('delete_module')}}",
                data:data,
                dataType:'json',
                success: window.location.reload()
            })
        }
    </script>
</head>
<body>

<form action="{{ url_for('add_module')}}" method="POST" id="new_module">
    <div id="news_module">
        <h2>添加模块</h2>
        <p>项目名称
            <select name="project_name">
                {% for project in projects%}
                <option value="{{project.project_name}}">{{project.project_name}}</option>
                {% endfor %}
            </select>
        </p>
        <p>编号               <input type="text" size="50" name="num"></p>
        <p>模块名称           <input type="text" size="50" name="module_name"></p>
        <p>创建者              <input type="text" size="50" name="creator"></p>
        <div class="di_buttom">
            <input id="sub_module" type="submit" value="提交">
            <input id="close_module" type="button" value="关闭" onclick="closewin_module()"></div>
        </div>
</form>
<form action="{{ url_for('editor_module')}}" method="POST" id="editor_module">
    <div id="editors_module">
        <h2>编辑模块</h2>
        <p>项目名称
            <select name="project_name1">
                {% for project in projects%}
                <option value="{{project.project_name}}">{{project.project_name}}</option>
                {% endfor %}
            </select>
        </p>
        <p>编号               <input type="text" size="50" name="num1"></p>
        <p>模块名称           <input type="text" size="50" name="module_name1"></p>
        <p>创建者              <input type="text" size="50" name="creator1"></p>

        <div class="di_buttom">
            <input id="sub_module1" type="submit" value="提交">
            <input id="close_module1" type="button" value="关闭" onclick="closewin_modul_editor()">
        </div>
    </div>
</form>
<form id="project_module" action="{{ url_for('project_module')}}"  method="POST">项目
    <select name="project">
        <option value="全部">全部</option>
        {% for project in projects%}
        <option value="{{project.project_name}}">{{project.project_name}}</option>
        {% endfor %}
    </select>
    <input type="submit" id="select_project" value="查询">
</form>
<div class="top_buttom">
    <input id="add_module" type="button" value="添加模块" onclick="openwin_module()">
</div>
<table border="2" cellpadding="8" style="border-collapse: collapse">
        <tr>
            <th>编号</th>
            <th>模块名称</th>
            <th>创建者</th>
            <th>操作</th>
        </tr>
        {% for module in modules %}
        <tr>
            <td>{{module.id}}</td>
            <td>{{module.module_name}}</td>
            <td>{{module.creator}}</td>
            <td><input type="button" value="编辑" onclick="editor_module(this)"><input type="button" value="删除" onclick="delmudole(this)"></td>
        </tr>
    {% endfor %}
</table>
</body>
</html>
{% endblock %}